<?php
/*******************************************************************************
 *
 *  Name: Customer Information Model
 *
 *  Date: 4/1/2012
 *  
 *  Description: This model allows access to the CustomerInfo table in our 
 *               database.
 *  
 *  Author: 
 *  
 *  Todo:
 *     NONE
 *
 *  Modification History:  
 * 
 *   Date         Name
 *  ----------   --------------
 *  2012-04-22   TRAVIS ROUS
 *  2012-04-09   HAYDEN WAISANEN
 * 
 *****************************************************************************/
?>
<?php
class Customerinfo_model extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
		$this->load->database();
    }
    
    function get($ReportID)
    {
        $query = $this->db->get_where('CustomerInfo', array('ReportID' => $ReportID));
        return $query->result_array();
    }
    function getAll()
    {
       $query = $this->db->get('CustomerInfo');
       return $query->result_array();
    }

    function insert($fields)
    {
        //Check if it already exists
        $query = $this->db->get_where('CustomerInfo', array('ReportID' => $fields['ReportID']));
        if( $query->num_rows() > 0 )
           return false;
		
		
        $this->db->insert('CustomerInfo', $fields);
        return true;
    }

    function update($fields)
    {
        $this->db->update('CustomerInfo', $fields, array('ReportID' => $fields['ReportID']));
    }
    function delete($fields)
    {
         $this->db->where('ReportID', $fields['ReportID']);
         $this->db->delete('CustomerInfo'); 
    }
}
?>
